<template>
    <div id="dialog-container">
        <el-dialog v-dialogDrag 
            :title="dialogTitle" append-to-body
            :visible.sync="dialogVisible" @close="$emit('update:show', false)" :before-close="handleClose" :show="show"
            :close-on-click-modal="false" width="700px">
            <el-form :model="form" :inline="true" size="small" label-width="100px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="检测类型：">
                            <el-input size="" v-model="form.sort" :disabled="true"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="生产厂家：">
                            <el-select v-model="optionVal" placeholder="请选择" style="width: 200px;">
                                <el-option v-for="item in options"
                                    :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="委托人：">
                            <el-input size="" v-model="form.name" :disabled="true"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="委托单位：">
                            <el-input size="" v-model="form.name" :disabled="true"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="委托日期：">
                            <el-input size="" v-model="form.name" :disabled="true"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8" :offset="1">
                        <el-button v-if="this.sort === 0" type="primary" size="small" @click="addTest">添加</el-button>
                        <el-button v-if="this.sort === 0" type="danger" size="small">批量删除</el-button>
                        <el-button v-if="this.sort === 1" type="primary" size="small" @click="addTest">修改</el-button>
                        <el-button v-if="this.sort === 2" type="primary" size="small" disabled>添加</el-button>
                    </el-col>
                </el-row>
            </el-form>
            <!-- 添加待检测弹框 -->
            <AddTestWait :show.sync="showTest"></AddTestWait>
            <el-table :data="tableData" border stripe size="mini">
                <el-table-column type="selection" width="50" align="center" :resizable="false"></el-table-column>
                <el-table-column type="index" label="序号" width="50" align="center" :resizable="false"></el-table-column>
                <el-table-column prop="status" label="计量器具状态" min-width="110" :resizable="false"></el-table-column>
                <el-table-column prop="" label="任务类型" min-width="90" :resizable="false"></el-table-column>
                <el-table-column prop="" label="任务单号" min-width="100" :resizable="false"></el-table-column>
                <el-table-column prop="" label="出厂编号" min-width="100" :resizable="false"></el-table-column>
                <el-table-column prop="" label="物料号" min-width="80" :resizable="false"></el-table-column>
                <el-table-column prop="" label="规格" min-width="60" :resizable="false"></el-table-column>
                <el-table-column prop="" label="器具名称" min-width="80" :resizable="false"></el-table-column>
                <el-table-column prop="" label="统一编号" min-width="90" :resizable="false"></el-table-column>
                <el-table-column prop="" label="样品分码" min-width="90" :resizable="false"></el-table-column>
                <el-table-column prop="" label="附件" min-width="100" :resizable="false"></el-table-column>
                <el-table-column prop="" label="操作" fixed="right" width="80">
                    <template slot-scope="scope">
                        <el-button type="danger" icon="el-icon-delete" size="mini"></el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
                <el-button @click="dialogVisible = false">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    import AddTestWait from 'dialog/test-manage/tool-check-accept/add-test-wait';
    export default {
        components: {
            AddTestWait
        },
        data() {
            return {
                dialogTitle: '新增新计量器具验收',
                dialogVisible: this.show,
                form: {
                    sort: '新计量器具验收',
                    name: ''
                },
                tableData: [{
                    status: '待提交'
                }],
                options: {},
                optionVal: '',
                showTest: false
            }
        },
        props: {
            show: {
                type: Boolean,
                default: false
            },
            // 判断弹框类型是新增或修改或详情
            sort: {
                type: Number,
                default: 0
            }
        },
        watch: {
            show() {
                this.dialogVisible = this.show;
                // 动态显示dialog的title
                this.sort === 0 ? this.dialogTitle='新增新计量器具验收' : this.sort === 1 ? this.dialogTitle='修改新计量器具验收' : this.dialogTitle='查看新计量器具验收';
            }
        },
        methods: {
            handleClose() {
                this.dialogVisible = false;
            },
            // 弹框： 添加待检测
            addTest(){
                this.showTest = true;
            }
        }
    }
</script>